package com.wysiwyg.gateway.security.jwt;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;


@Data
@Validated
@ConfigurationProperties(prefix= JwtProperties.JWT_PREFIX)
public class JwtProperties {
    static final String JWT_PREFIX= "jwt.config";
    /**
     * 是否可用
     */
    private boolean enabled;
    /**
     * jks 路径
     */
    @NotBlank(message = "JWT密钥文件路径不能为空")
    private String keyLocation;
    /**
     * key alias
     */
    @NotBlank(message = "JWT密钥别名不能为空")
    private String keyAlias;
    /**
     * key store pass
     */
    @NotBlank(message = "JWT密钥密码不能为空")
    private String keyPass;
    /**
     * jwt签发者
     **/
    @NotBlank(message = "JWT签发者不能为空")
    private String iss;
    /**
     * jwt所面向的用户
     **/
    @NotBlank(message = "JWT受众不能为空")
    private String aud;
    /**
     * access jwt token 有效天数
     */
    @Min(value = 1, message = "访问令牌有效期必须大于0天")
    private int accessExpDays;
    /**
     * refresh jwt token 有效天数
     */
    @Min(value = 1, message = "刷新令牌有效期必须大于0天")
    private int refreshExpDays;
}
